package com.example.activemq.producer;

import org.apache.activemq.command.ActiveMQQueue;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.jms.Destination;


/**
 * 消息生产者
 * @date 2019-4-4 10:55:38
 * @author joker
 */
@Service
public class Producer {

    @Resource
    private JmsMessagingTemplate jmsMessagingTemplate;

    public void sendMessage(String queue, String message){
        System.out.println("===========>>>>发送队列消息<<<<=============");
        Destination destination = new ActiveMQQueue(queue);
        jmsMessagingTemplate.convertAndSend(destination, "生产者发送的消息：" + message);
    }
}
